#include "../include/NDK.h"
#include <errno.h>
#include <iostream>
#include <unistd.h>

int main ()
{
    std::cout << "wait for your input ...\n";
    char buff[1024] = {0};
#if 0
    NDK::set_non_block_mode (0);
#else
    int flag = 0;
    NDK::record_and_set_non_block_mode(0, flag);
#endif
    while (1)
    {
	int ret = read (0, buff, sizeof(buff));
	if (ret == -1 && errno == EAGAIN)
	{
	    std::cout << "ewouldblock\n";
#if 0
	    NDK::set_block_mode (0);
#else
	    NDK::restore_non_block_mode(0, flag);
#endif
	}
	buff[ret] = '\0';
	printf (buff);
    }
    return 0;
}
